package com.wenx.concurrent;

import java.util.concurrent.TimeUnit;

/**
 * Created by wenx on 2019-10-15 18:54
 */
public class ThStaticExam {

    public static synchronized void testa() {
        System.out.println("a方法");
        try {
            TimeUnit.SECONDS.sleep(5);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        System.out.println("a方法完成");
    }

    public static synchronized void testb() {
        System.out.println("b方法");
        try {
            TimeUnit.SECONDS.sleep(5);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        System.out.println("b方法完成");
    }

    public static void testc() {
        synchronized (ThStaticExam.class) {
            System.out.println("c方法");
            try {
                TimeUnit.SECONDS.sleep(5);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            System.out.println("c方法完成");
        }
    }

    public static void testd() {
        synchronized (ThStaticExam.class) {
            System.out.println("d方法");
            try {
                TimeUnit.SECONDS.sleep(5);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            System.out.println("d方法完成");
        }
    }

}